package cn.liujianbo.example.springbean.bean5.component;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author 刘建波
 * @date 2021-10-10 20:16
 */
@Component
public class UserService implements InitializingBean {
    @Autowired
    public OrderService orderService;

    public UserService(){
        System.out.println("orderService = " + orderService);
    }

    private int salt;

    @PostConstruct
    private void setSalt(){
        // 查询数据库，设置 salt
        System.out.println("执行了 @PostConstruct 注释的方法");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("执行了 InitializingBean接 口的 afterPropertiesSet 方法");
    }

    public void test(){
        System.out.println("userService.test()方法执行");
    }
}
